﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using ShardingWTM.Models;


namespace ShardingWTM.ProjectManage.ViewModels.ProjectInfoVMs
{
    public partial class ProjectInfoListVM : BasePagedListVM<ProjectInfo_View, ProjectInfoSearcher>
    {
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("ProjectInfo", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"ProjectManage", dialogWidth: 800),
                this.MakeStandardAction("ProjectInfo", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "ProjectManage", dialogWidth: 800),
                this.MakeStandardAction("ProjectInfo", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "ProjectManage", dialogWidth: 800),
                this.MakeStandardAction("ProjectInfo", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "ProjectManage", dialogWidth: 800),
                this.MakeStandardAction("ProjectInfo", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "ProjectManage", dialogWidth: 800),
                this.MakeStandardAction("ProjectInfo", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "ProjectManage", dialogWidth: 800),
                this.MakeStandardAction("ProjectInfo", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "ProjectManage", dialogWidth: 800),
                this.MakeStandardAction("ProjectInfo", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "ProjectManage"),
            };
        }


        protected override IEnumerable<IGridColumn<ProjectInfo_View>> InitGridHeader()
        {
            return new List<GridColumn<ProjectInfo_View>>{
                this.MakeGridHeader(x => x.ProjectName),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<ProjectInfo_View> GetSearchQuery()
        {
            var query = DC.Set<ProjectInfo>()
                .CheckContain(Searcher.ProjectName, x=>x.ProjectName)
                .Select(x => new ProjectInfo_View
                {
				    ID = x.ID,
                    ProjectName = x.ProjectName,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class ProjectInfo_View : ProjectInfo{

    }
}
